home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3988 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: colossus.holonet.net!russell
  2. From: russell@news.mdli.com (Russell Blackadar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q:order of evaluation
  5. Date: 27 Jan 1996 02:21:53 GMT
  6. Organization: HoloNet National Internet Access System: 510-704-1058/modem
  7. Message-ID: <4ec281$ctb@colossus.holonet.net>
  8. References: <4dfhlu$a33$1@mhafn.production.compuserve.com> <hamilton-1801962045570001@dialup-147.austin.io.com> <4dpcfo$293@clarknet.clark.net> <hamilton-2401960104020001@dialup-86.austin.io.com> <3108c867.40236096@nntp.ix.netcom.com> <4eb6kq$ksf@gazette.tandem.com>
  9. NNTP-Posting-Host: jubal.mdli.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. yun_yeogirl (yyg) wrote:
  13. : Michael M Rubenstein wrote :
  14.  
  15. :         [Example:
  16. :           i = v[i++];      // the behavior is undefined
  17. :           i = 7,i++,i++;   // `i' becomes 9
  18.  
  19. :           i = ++i + 1;     // the behavior is undefined
  20. :           i = i + 1;       // the value of 'i' is incremented
  21.  
  22. : The first and third statement seem clear to me. I don't see why they are
  23. : undefined. 
  24.  
  25. Read the previous post again, carefully.  Both these statements modify
  26. i twice with no intervening sequence point, and that is always undefined.
  27. (The rule is actually stronger, as others have pointed out, but double
  28. modification is an easy thing to look for here.)  It doesn't matter that
  29. they look clear to you; they will look unclear to the compiler!  One simply
  30. has to get used to this.
  31.  
  32. : I guess you made a typo here. Maybe you meant :
  33.  
  34. :     i + v[i++] and i + (++i + 1).
  35.  
  36. Those would also be undefined, of course. 
  37. --
  38. Russell Blackadar,   russell@mdli.com
  39.